package com.ruoyi.web.controller.sz;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.system.domain.sz.SzLeaderGroupSnapshot;
import com.ruoyi.system.service.sz.ISzLeaderGroupSnapshotService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 领导小组&密码办Controller
 * 
 * @author ruoyi
 * @date 2024-03-16
 */
@Anonymous
@RestController
@RequestMapping("/sz/snapshot")
public class SzLeaderGroupSnapshotController extends BaseController
{
    @Autowired
    private ISzLeaderGroupSnapshotService szLeaderGroupSnapshotService;

    /**
     * 查询领导小组&密码办列表
     */
//    @PreAuthorize("@ss.hasPermi('sz:snapshot:list')")
    @GetMapping("/list")
    public TableDataInfo list(SzLeaderGroupSnapshot szLeaderGroupSnapshot)
    {
        startPage();
        List<SzLeaderGroupSnapshot> list = szLeaderGroupSnapshotService.selectSzLeaderGroupSnapshotList(szLeaderGroupSnapshot);
        return getDataTable(list);
    }

    /**
     * 导出领导小组&密码办列表
     */
//    @PreAuthorize("@ss.hasPermi('sz:snapshot:export')")
//    @Log(title = "领导小组&密码办", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SzLeaderGroupSnapshot szLeaderGroupSnapshot)
    {
        List<SzLeaderGroupSnapshot> list = szLeaderGroupSnapshotService.selectSzLeaderGroupSnapshotList(szLeaderGroupSnapshot);
        ExcelUtil<SzLeaderGroupSnapshot> util = new ExcelUtil<SzLeaderGroupSnapshot>(SzLeaderGroupSnapshot.class);
        util.exportExcel(response, list, "领导小组&密码办数据");
    }

    /**
     * 获取领导小组&密码办详细信息
     */
//    @PreAuthorize("@ss.hasPermi('sz:snapshot:query')")
    @GetMapping(value = "/{groupId}")
    public AjaxResult getInfo(@PathVariable("groupId") Long groupId)
    {
        return success(szLeaderGroupSnapshotService.selectSzLeaderGroupSnapshotByGroupId(groupId));
    }

    /**
     * 新增领导小组&密码办
     */
//    @PreAuthorize("@ss.hasPermi('sz:snapshot:add')")
//    @Log(title = "领导小组&密码办", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SzLeaderGroupSnapshot szLeaderGroupSnapshot)
    {
        return toAjax(szLeaderGroupSnapshotService.insertSzLeaderGroupSnapshot(szLeaderGroupSnapshot));
    }



    /**
     * 修改领导小组&密码办
     */
//    @PreAuthorize("@ss.hasPermi('sz:snapshot:edit')")
//    @Log(title = "领导小组&密码办", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SzLeaderGroupSnapshot szLeaderGroupSnapshot)
    {
        return toAjax(szLeaderGroupSnapshotService.updateSzLeaderGroupSnapshot(szLeaderGroupSnapshot));
    }

    /**
     * 删除领导小组&密码办
     */
//    @PreAuthorize("@ss.hasPermi('sz:snapshot:remove')")
//    @Log(title = "领导小组&密码办", businessType = BusinessType.DELETE)
	@DeleteMapping("/{groupIds}")
    public AjaxResult remove(@PathVariable Long[] groupIds)
    {
        return toAjax(szLeaderGroupSnapshotService.deleteSzLeaderGroupSnapshotByGroupIds(groupIds));
    }
}
